import java.util.*;
/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 09 - 26
 * Time: 11:45
 */
//牛客 排序子序列
public class Solution6 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n + 1];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            int i = 0;
            int count = 0;
            while (i < n) {
                if(arr[i] < arr[i + 1]) {
                    while (i < n && arr[i] < arr[i + 1]) {
                        i++;
                    }
                    count++;
                    i++;
                } else if (arr[i] == arr[i + 1]) {
                    i++;
                }else {
                    while (i < n && arr[i] > arr[i + 1]) {
                        i++;
                    }
                    count++;
                    i++;
                }
            }
            System.out.println(count);
        }
    }
}
